package com.api.gbhg.liubing.action;

import com.api.gbhg.liuwenbo.action.OfficeSupplies;
import com.api.gbhg.liwenjun.GBHGConstant;
import com.api.gbhg.liwenjun.VersionFlowUtil;
import com.api.gbhg.liubing.dao.CommonMethod;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import weaver.conn.RecordSet;
import weaver.interfaces.workflow.action.Action;
import weaver.soa.workflow.request.RequestInfo;

import java.util.HashMap;
import java.util.Map;

/**
 * @author : liubing
 * @date :  2020/12/29 14:54
 * 教育培训经费
 */
public class EducationTraining implements Action {
    private static final Logger log = LoggerFactory.getLogger("gbhg");
    @Override
    public String execute(RequestInfo requestInfo) {
        log.info("-----------------教育培训经费------------------------");
        Map<String,String> map = new HashMap<>();
        String flowTableName = VersionFlowUtil.getFlowTableName(requestInfo.getWorkflowid());
        map.put("xmmin", "xmmc");
        map.put("yszje","zfcgyswy");
        //同步流程数据到版本表、主表
        boolean isSuccess = VersionFlowUtil.
                sysDataToVersion(requestInfo.getRequestid(), requestInfo.getWorkflowid(),
                        GBHGConstant.FlowVersionTableEnum.uf_jypxjf, map);

        boolean b = CommonMethod.updateTotalBudgetAmount(requestInfo.getRequestid(),requestInfo.getWorkflowid());//修改预算总金额
        log.info("同步数据：---》"+isSuccess);
        log.info("修改金额：---》"+b);
        if(!(isSuccess && b)){
            requestInfo.getRequestManager().setMessagecontent("同步建模表异常");
            requestInfo.getRequestManager().setMessageid("");
            log.info("同步流程数据到版本表失败！");
            return FAILURE_AND_CONTINUE;
        }else {
            return SUCCESS;
        }
    }
}
